home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C & C++ Multimedia Cyber Classroom
/
C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso
/
install.sh
< prev
next >
Wrap
Linux/UNIX/POSIX Shell Script
|
1998-03-05
|
35KB
|
995 lines
#!/bin/sh
# install.sh
# Prentice Hall CyberClassroom Solaris installation script.
# Deitel C++ How To Program 2e
SCRIPT_NAME="$0"
# FUNCTION: cleanup()
# DESCRIPTION: To uninstall any aborted attempted install, cleanup the "footprints" of any thing the
# install did to the user's system, and return with the specified error code.
# ARGUMENTS: $1 - The error code to exit this script with.
# GLOBALS: Assumes $UNINSTALL_LINE1 $UNINSTALL_LINE2 $UNINSTALL_LINE3 $UNINSTALL_LINE4 are set if need be.
# RETURN VALUE: NONE
cleanup()
{
echo
echo "$SCRIPT_NAME: Installation Aborted, cleaning up..."
echo
$UNINSTALL_LINE1
$UNINSTALL_LINE2
$UNINSTALL_LINE3
$UNINSTALL_LINE4
exit $1
}
# FUNCTION: two_value_question()
# DESCRIPTION As a question of the user for input that has 2 allowable answers.
# The first argument is the first allowable answer the user can type in and
# also the default answer if the user just hits the enter key. The second argument
# is the other allowable answer. The comparison is case INDEPENDENT, in other
# words the answer "YeS" is the same as "yes". Also the first letter of the answer
# is all that is required, however if the user chooses to type the full allowable answer
# then ONLY the first character is checked, in other words "Yasdfa" will be interpreted
# as a valid "YES".
#
# ARGUMENTS: $1 - first allowable value and also the prompt default
# $2 - Second allowable value
# GLOBALS: Assumes $L1 $L2 $L3 $L4 $L5 $L6 $L7 are set if need be.
# RETURN VALUE: $PROMPT_ANSWER set a the first character of the selected prompt.
two_value_question()
{
FIRST_CHAR_OF_ARG1=`echo $1 | tr "[:lower:]" "[:upper:]" | awk '{print substr($1,1,1)}'`
FIRST_CHAR_OF_ARG2=`echo $2 | tr "[:lower:]" "[:upper:]" | awk '{print substr($1,1,1)}'`
QUIT_WHILE=0
while [ $QUIT_WHILE -eq 0 ]
do
echo
if [ "$L1" != "" ]; then
echo $L1
fi
if [ "$L2" != "" ]; then
echo $L2
fi
if [ "$L3" != "" ]; then
echo $L3
fi
if [ "$L4" != "" ]; then
echo $L4
fi
if [ "$L5" != "" ]; then
echo $L5
fi
if [ "$L6" != "" ]; then
echo $L6
fi
if [ "$L7" != "" ]; then
echo $L7
fi
read A_OR_B
if [ "$A_OR_B" = "" ]; then
A_OR_B=$1
fi
PROMPT_ANSWER=`echo $A_OR_B | tr "[:lower:]" "[:upper:]" | awk '{print substr($1,1,1)}'`
if [ "$PROMPT_ANSWER" != "$FIRST_CHAR_OF_ARG1" -a "$PROMPT_ANSWER" != "$FIRST_CHAR_OF_ARG2" ]; then
echo
echo "Please answer with \"$1\"" or \"$2\"". Try again."
else
QUIT_WHILE=1
fi
done
return 0
}
trap 'echo;echo "Ctrl-C detected";echo;cleanup 1' 2
CYBERCLASSROOM_JRE_VERSION="1.1.5"
CYBERCLASSROOM_JRE_DIRECTORY="jre1.1.5"
CYBERCLASSROOM_VIEWER_VERSION="1.2.0"
#SOLARIS_JRE_RUNTIME=jre115-solaris2-sparc.exe
SOLARIS_JRE_RUNTIME=jre115s.exe
CDROM_DIR=`/usr/bin/pwd`
CYBERCLASSROOM_BOOK_DIR=cpphtp2
CYBERCLASSROOM_BOOK_FILE=cpphtp2.jar
CYBERCLASSROOM_INITIALIZATION_FILE=webdb.ini
CYBERCLASSROOM_HTML_FILE=cpphtp2.htm
CYBERCLASSROOM_VIEWER_DIR=viewer
CYBERCLASSROOM_BOOK_SCRIPT=cpphtp2.sh
CYBERCLASSROOM_BOOK_UNINSTALL_SCRIPT=uninstall.sh
# This book requires at least 350MB of disk space for Full Installation.
CYBERCLASSROOM_BOOK_REQUIRED_SPACE_IN_MB_FOR_FULL=350
CYBERCLASSROOM_BOOK_REQUIRED_SPACE_IN_MB_FOR_COMPACT=35
CYBERCLASSROOM_BOOK_REQUIRED_SPACE_IN_K_FOR_FULL=358400
CYBERCLASSROOM_BOOK_REQUIRED_SPACE_IN_K_FOR_COMPACT=35840
UNINSTALL_LINE1=""
UNINSTALL_LINE2=""
UNINSTALL_LINE3=""
UNINSTALL_LINE4=""
echo
echo "********************************************************************"
echo "** Welcome to the Prentice Hall CyberClassroom Installation Script *"
echo "** *"
echo "** Please follow the prompts where requested. Options for each *"
echo "** prompt are enclosed inside circular parenthesis () characters. *"
echo "** Only the first character for each prompt is necessary, such as *"
echo "** \"y\" for \"yes\" and \"n\" for \"no\". Default values for each *"
echo "** prompt are enclosed inside [] characters. *"
echo "********************************************************************"
# No arguments required for this script
if [ $# -ne 0 ]; then
echo
echo "Note: no arguments are required for this installation script."
echo "The arguments will be ignored."
echo
fi
# Warning message if the current user is not "root"
if [ "$USER" != "root" ]; then
L5=""; L6=""; L7=""
L1="WARNING: This installation script creates files and directories "
L2="on local mount points. Unless you have proper file permissions "
L3="the installation may not proceed properly."
L4="Continue installation as user \"$USER\" ? (yes|no) [no]: \c"
two_value_question no yes
if [ "$PROMPT_ANSWER" != "Y" ]; then
cleanup 5
fi
echo
fi
INSTALL_JRE=1
JRE_LOCATION=/opt
L2=""; L3=""; L4=""; L5=""; L6=""; L7=""
L1="Do you have the SunSoft JRE installed ? (yes|no) [no]: \c"
two_value_question no yes
if [ "$PROMPT_ANSWER" = "Y" ]; then
while [ 1 ]
do
JRE_LOCATION=/opt
INSTALL_JRE=0
# Ask for the "jre" in the current path
echo
echo "Where is the SunSoft JRE installed ? (ex: \"/opt/apps/jre${CYBERCLASSROOM_JRE_VERSION}\"): \c"
read RESPONSE
if [ "$RESPONSE" = "" ]; then
echo
echo "You must type a location, such as \"/opt/apps/jre${CYBERCLASSROOM_JRE_VERSION}\". Try again."
echo
continue
fi
JRE_LOCATION=$RESPONSE
# Check to see if the user is right
if [ ! -d $JRE_LOCATION ]; then
echo
echo "The directory \"$JRE_LOCATION\" does not exist on your system."
echo "Please try another path."
echo
continue
fi
# OK Now we have the location
JRE_EXECUTABLE=$JRE_LOCATION/bin/jre
# Check for the JRE and run it, make sure its the version
# CyberClassroom needs or a version
# that is later.
if [ ! -f $JRE_EXECUTABLE ]; then
TMP_JRE_LOCATION=$JRE_LOCATION/jre${CYBERCLASSROOM_JRE_VERSION}
TMP_JRE_EXECUTABLE=$TMP_JRE_LOCATION/bin/jre
if [ ! -f $TMP_JRE_EXECUTABLE ]; then
L5=""; L6=""; L7=""
L1="The executable \"$TMP_JRE_EXECUTABLE\" does not exist "
L2="Maybe there is a damaged installation of a previous JRE."
L3="Do you wish to reinstall the JRE in the directory"
L4="\"$JRE_LOCATION\" ? (yes/no) [yes]: \c"
two_value_question yes no
if [ "$PROMPT_ANSWER" = "Y" ]; then
INSTALL_JRE=1
break
else
L2=""; L3=""; L4=""; L5=""; L6=""; L7=""
L1="Choose another location? (yes/no) [yes]: \c"
two_value_question yes no
if [ "$PROMPT_ANSWER" = "Y" ]; then
continue
else
echo
echo "$0: ERROR: A possibly damaged installation of the JRE was detected"
echo "in the directory \"$JRE_LOCATION\"."
echo "Please correct this problem and run this installation again."
cleanup 15
fi
fi
else
JRE_LOCATION=$TMP_JRE_LOCATION
JRE_EXECUTABLE=$TMP_JRE_EXECUTABLE
fi
fi
CURRENT_JRE=`$JRE_EXECUTABLE -help 2>&1 | grep -i Version | awk '{print $NF}'`
if [ `echo $CURRENT_JRE | awk -F. '{print $1$2$3$4}'` -ne `echo $CYBERCLASSROOM_JRE_VERSION | awk -F. '{print $1$2$3$4}'` ]; then
L7=""
L1="The JRE executable [$CURRENT_JRE] on your system"
L2="is not the version used by the CyberClassroom JRE "
L3="[jre version \"$CYBERCLASSROOM_JRE_VERSION\"]."
L4="If you are using a version older than this,"
L5="it is recommended you install the CyberClassroom JRE version as well."
L6="Continue and use existing JRE ? (yes/no) [no]: \c"
two_value_question no yes
if [ "$PROMPT_ANSWER" = "Y" ]; then
INSTALL_JRE=0
else
INSTALL_JRE=1
fi
break
else
break
fi
done
fi
# If the JRE needs inst